package com.zhengshang.web.controller.app;

import java.util.List;

import com.zhengshang.common.enums.UserStatus;
import com.zhengshang.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhengshang.common.annotation.Log;
import com.zhengshang.common.core.controller.BaseController;
import com.zhengshang.common.core.domain.AjaxResult;
import com.zhengshang.common.enums.BusinessType;
import com.zhengshang.api.domain.AppCashingRecord;
import com.zhengshang.api.service.IAppCashingRecordService;
import com.zhengshang.common.utils.poi.ExcelUtil;
import com.zhengshang.common.core.page.TableDataInfo;

/**
 * APP用户提现记录Controller
 * 
 * @author zhengshang
 * @date 2021-03-30
 */
@RestController
@RequestMapping("/app/cashing")
public class AppCashingRecordController extends BaseController
{
    @Autowired
    private IAppCashingRecordService appCashingRecordService;

    /**
     * 查询APP用户提现记录列表
     */
    @PreAuthorize("@ss.hasPermi('app:cashing:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppCashingRecord appCashingRecord)
    {
        appCashingRecord.setDelFlag(UserStatus.OK.getCode());
        startPage();
        List<AppCashingRecord> list = appCashingRecordService.selectAppCashingRecordList(appCashingRecord);
        return getDataTable(list);
    }

    /**
     * 导出APP用户提现记录列表
     */
    @PreAuthorize("@ss.hasPermi('app:cashing:export')")
    @Log(title = "APP用户提现记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppCashingRecord appCashingRecord)
    {
        List<AppCashingRecord> list = appCashingRecordService.selectAppCashingRecordList(appCashingRecord);
        ExcelUtil<AppCashingRecord> util = new ExcelUtil<AppCashingRecord>(AppCashingRecord.class);
        return util.exportExcel(list, "APP用户提现记录");
    }

    /**
     * 获取APP用户提现记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:cashing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(appCashingRecordService.selectAppCashingRecordById(id));
    }

//    /**
//     * 新增APP用户提现记录
//     */
//    @PreAuthorize("@ss.hasPermi('app:cashing:add')")
//    @Log(title = "APP用户提现记录", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody AppCashingRecord appCashingRecord)
//    {
//        return toAjax(appCashingRecordService.insertAppCashingRecord(appCashingRecord));
//    }

    /**
     * 修改APP用户提现记录
     */
    @PreAuthorize("@ss.hasPermi('app:cashing:edit')")
    @Log(title = "APP用户提现记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppCashingRecord appCashingRecord)
    {
        appCashingRecord.setUpdateBy(SecurityUtils.getUsername());
        return toAjax(appCashingRecordService.updateAppCashingRecord(appCashingRecord));
    }

//    /**
//     * 删除APP用户提现记录
//     */
//    @PreAuthorize("@ss.hasPermi('app:cashing:remove')")
//    @Log(title = "APP用户提现记录", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids)
//    {
//        return toAjax(appCashingRecordService.deleteAppCashingRecordByIds(ids));
//    }
}
